<?
include ('../funct.php');

echo '<html>
 <head>
 <script src="../js/calendar.js" type="text/javascript"></script>
<link href="../css/calendar.css" rel="stylesheet" type="text/css"/>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
';

?>


 <?php
 html();
 
require_once("../calendar/class/class.oCalendarPicker.php");
 	$aMonthNames=array(
		"PL"=>array("Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień")
 	);
 	$aDaysNames=array(
 		"FR"=>array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"),
 		"EN"=>array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"),
		"PL"=>array("Poniedziałek", "Wtorek", "Sroda", "Czwartek", "Piątek", "Sobota", "Niedziela")
	);
 	$sDateFormat=array(
 		"FR"=>"d/m/Y",
 		"EN"=>"Y-m-d",
		"PL"=>"Y-m-d"
	);
	
	$sDate=(!empty($_GET['sDate']))?$_GET['sDate']:date("Ymd");
?>
		 


 
 <table cellspacing="0" cellpadding="30" border="0">
 <form action="grafik_oblozenie.php" method="post">
 <tr>
 
 		<td>
 <?php
 /**
  * 
  * Display Calendar and fill field
  * 
  * 
  */
 $aCalendarParams=array(
 "sIconPath"     =>  "../calendar/img/calendar.png",
 "iAction"       =>  1,   //0=>reloadCurrentPage with get param sDate, 1=>fill field sFieldName
 "sFieldName"    =>  "Date1",
 "iStyle"        =>  1,   //0=>display calendar, 1=>display div on icon click
 "aMonthNames"   =>  $aMonthNames["PL"],
 "aDaysNames"    =>  $aDaysNames["PL"],
 "sDateFormat"   =>  $sDateFormat["PL"]

 );
new oCalendarPicker("calFixe2",$sDate,$aCalendarParams);
      ?><input type="text" name="Date1" id="Date1" value="<? echo $_POST['Date1']?>"/><br>Data początku
      </td>
<td>
 <?php
 /**
  * 
  * Display Calendar and fill field
  * 
  * 
  */
 $aCalendarParams=array(
 "sIconPath"     =>  "../calendar/img/calendar.png",
 "iAction"       =>  1,   //0=>reloadCurrentPage with get param sDate, 1=>fill field sFieldName
 "sFieldName"    =>  "Date2",
 "iStyle"        =>  1,   //0=>display calendar, 1=>display div on icon click
 "aMonthNames"   =>  $aMonthNames["PL"],
 "aDaysNames"    =>  $aDaysNames["PL"],
 "sDateFormat"   =>  $sDateFormat["PL"]

 );
new oCalendarPicker("calFixe3",$sDate,$aCalendarParams);
      ?><input type="text" name="Date2" id="Date2" value="<? echo $_POST['Date2']?>"/><br>Data końca
      </td>	  
	  
	  
 <td><input type="submit" value="Pokaż"></td></tr>
 </table>
 </form>
 <?
 
 $sql="select sl_gab.nazwa, count(wizyty.id_gab), sl_gab.id from wizyty, sl_gab, user_gab where wizyty.akt = 1 and wizyty.id_gab = sl_gab.id and sl_gab.id = user_gab.id_gab and user_gab.id_user=".$_SESSION['uzytk']['id']." and wizyty.data >= '".$_POST['Date1']."%'  and wizyty.data <= '".$_POST['Date2']."%' group by sl_gab.nazwa";
# echo $sql;
echo '<table class="linia" align="center">';
$result=mysql_query($sql);
	while($row = mysql_fetch_array($result))
	{
	
	echo '<tr><td align="center">';
	echo '<b>'.$row[0].' - '.$row[1].' pacjentów</b><br>';
	$sql2="select DATE_FORMAT(wizyty.data,'%Y-%m-%d'), pac.pac_nazwisko, pac.pac_imie, sl_uslugi.nazwa from pac, wizyty, sl_uslugi where sl_uslugi.id = wizyty.typ_wiz and pac.id = wizyty.id_pac and wizyty.id_gab=".$row[2]." and wizyty.data >= '".$_POST['Date1']."%'  and wizyty.data <= '".$_POST['Date2']."%' and wizyty.akt = 1 order by wizyty.data";
	#echo $sql2;
	$result2=mysql_query($sql2);
	echo '<table width=100%>';
	while($row2 = mysql_fetch_array($result2))
	{
	echo '<tr><td class="linia">'.$row2[0].'</td><td class="linia">'.$row2[3].'</td><td class="linia">'.$row2[1].' '.$row2[2].'</td></tr>';
	}
	echo '</table>';
	echo '</td></tr>';
	echo '<tr><td align="center">Podsumowanie:</td></tr>';
	$sql3="select sl_uslugi.nazwa, count(sl_uslugi.nazwa) from pac, wizyty, sl_uslugi where sl_uslugi.id = wizyty.typ_wiz and pac.id = wizyty.id_pac and wizyty.id_gab=".$row[2]." and wizyty.data >= '".$_POST['Date1']."%'  and wizyty.data <= '".$_POST['Date2']."%' and wizyty.akt = 1 group by sl_uslugi.nazwa";
	$result3=mysql_query($sql3);
	echo '<tr><td><table width=100%>';
	while($row3 = mysql_fetch_array($result3))
	{
	echo '<tr><td class="linia">'.$row3[0].'</td><td class="linia">'.$row3[1].'</td></tr>';
	}
	echo '</td></tr></table>';
	}
	
 echo '</table>';
 
 ?>     
</body>
</html>
<?
#zmienne();
?>